#ifndef LAMP_DETECTOR_H_
#define LAMP_DETECTOR_H_

#include <vector>
using namespace std;

#include "coexistence_matrix/coexistence_matrix.h"
#define MAX_DETECTABLE_OBJECTS 2000

struct lamp {
	double x;
	double y;
};

class LampDetector {
private:

	CoexistenceMatrix *coexistence_matrix;
	int **label_space;
	int nof_found_objects;
	int images_width;
	int images_height;
	bool debug;
	int detection;

	struct ObjectInImage {
		int xmin, xmax, ymin, ymax, area, sigma_x, sigma_y;
		bool used;

		ObjectInImage() {
		  Clear();
		}

		void Clear() {
      xmin = ymin = 2147483647;
      xmax = ymax = area = sigma_x = sigma_y = 0;
      used = false;
		}
	} *found_objects;

	bool TestForCircle(int object_to_test_index);

	bool TestForRectangle(int object_to_test_index);

public:
	LampDetector(int images_width, int images_height, bool debug);

	~LampDetector();

	std::vector<lamp> DetectLamps(int **binarized_image, int min_detectable_area,
			                      int max_width_variance, int min_width_simetry,
			                      double image_scale);

};
#endif
